package com.zhuss.core.auth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.core.auth.AuthBo;
import com.zhuss.bean.vo.core.auth.AuthResourceVo;
import com.zhuss.bean.vo.core.auth.AuthVo;
import com.zhuss.common.AuthOperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.OceanException;

/**
 * 用户的权限service（基本）
 * @author zhushanshuo
 * @Date 2019-12-13 15:59
 *
 */
@Component("authService")
public class AuthService implements AuthOperateService<Object, Object> {
	
	
	@Autowired
	@Qualifier("authProcessor")
	private Processor<AuthVo, AuthBo> authProcessor;
	
	@Autowired
	@Qualifier("authTreeProcessor")
	private Processor<AuthVo, AuthBo> authTreeProcessor;
	
	@Autowired
	@Qualifier("authResourceProcessor")
	private Processor<AuthResourceVo, AuthBo> authResourceProcessor;
	
	/**
	 * 用户的权限
	 */
	@Override
	public Object menu(Object param) throws OceanException {
		
		AuthBo bo = (AuthBo) param;
		Object result = authProcessor.process(bo);
		return result;
	}
	
	/**
	 * 用户的权限
	 */
	@Override
	public Object menuTree(Object param) throws OceanException {
		
		AuthBo bo = (AuthBo) param;
		Object result = authTreeProcessor.process(bo);
		return result;
	}
	
	
	/**
	 * 用户的接口权限
	 */
	@Override
	public Object resource(Object param) throws OceanException {
		
		AuthBo bo = (AuthBo) param;
		Object result = authResourceProcessor.process(bo);
		return result;
	}
	
}

